import java.util.Arrays;

public class MyStack {

    public int elem[];
    public int usedSize;
    public MyStack(){
        elem=new int[10];
    }

    public void push(int val){
        if(isFull()){
            elem=Arrays.copyOf(elem,elem.length*2);
        }
        elem[usedSize]=val;
        usedSize++;
    }

    public boolean isFull(){
        return usedSize==elem.length;
    }

    public boolean isEmpty(){
        return usedSize==0;
    }

    public int pop(){
    if(isEmpty()){
        throw new StackException("pop中栈为空!!!");
    }
    int val=elem[usedSize-1];
    usedSize--;
    return val;
    }


}
